from operator import itemgetter

rows = [
    {'fname':'Brian', 'lname':'Jones', 'uid':1001},
    {'fname':'David', 'lname':'Beazley', 'uid':1002},
    {'fname':'John', 'lname':'Cleese', 'uid':1003},
    {'fname':'Big', 'lname':'Jones', 'uid':1004}
]

rows_by_fname = sorted(rows,key=itemgetter('fname'))
rows_by_uid = sorted(rows,key=itemgetter('uid'))

print('-----------rows_by_fname------------')
print(rows_by_fname)

print('-----------rows_by_uid------------')
print(rows_by_uid)

rows_by_fname_uid = sorted(rows,key=itemgetter('lname','fname'))
print('-----------rows_by_fname_uid------------')
print(rows_by_fname_uid)


print(min(rows,key=itemgetter('uid')))
print(max(rows,key=itemgetter('uid')))